# -*- makefile -*-

.PHONY: all test petsc-30 petsc-31 petsc-dev

MPIEXEC  =
VALGRIND =
PYTHON   = python

PETSC_30=/home/devel/petsc/3.0
PETSC_31=/home/devel/petsc/3.1
PETSC_32=/home/devel/petsc/3.2
PETSC_DEV=/home/devel/petsc/dev

#PETSC_ARCH=linux-gnu

all: petsc-30 petsc-31 petsc-dev

MAKE_ARGS= -f misc/makefile.dev MPIEXEC='${MPIEXEC}' VALGRIND='${VALGRIND}' PYTHON='${PYTHON}'
petsc-30:
	${MAKE} ${MAKE_ARGS} PETSC_DIR=${PETSC_30} PETSC_ARCH=${PETSC_ARCH} test
petsc-31:
	${MAKE} ${MAKE_ARGS} PETSC_DIR=${PETSC_31} PETSC_ARCH=${PETSC_ARCH} test
petsc-32:
	${MAKE} ${MAKE_ARGS} PETSC_DIR=${PETSC_32} PETSC_ARCH=${PETSC_ARCH} test
petsc-dev:
	${MAKE} ${MAKE_ARGS} PETSC_DIR=${PETSC_DEV} PETSC_ARCH=${PETSC_ARCH} test


TEST_DIR=/tmp/petsc4py-build-test
test:
	${RM} -r build
	${RM} -r ${TEST_DIR}/lib/python/petsc4py*
	${RM} -r ${TEST_DIR}/lib64/python/petsc4py*
	${PYTHON} setup.py clean --all
	${PYTHON} setup.py install --home=${TEST_DIR}
	${RM} -r build
	PYTHONPATH=${TEST_DIR}/lib64/python:${TEST_DIR}/lib/python \
	${MPIEXEC} ${VALGRIND} ${PYTHON} test/runtests.py --summary
	${RM} conf/*.py[co]
	${RM} tests/*.py[co]
	${RM} -r ${TEST_DIR}/lib/python/petsc4py*
	${RM} -r ${TEST_DIR}/lib64/python/petsc4py*
